package com.wqtz.chechai.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.orhanobut.logger.Logger;
import com.wqtz.chechai.R;
import com.wqtz.chechai.base.lvbaseadapter.LvBaseAdapter;
import com.wqtz.chechai.base.lvbaseadapter.ViewHolder;
import com.wqtz.chechai.base.rebaseadapter.MyHolder;
import com.wqtz.chechai.base.rebaseadapter.RecyclerAdapter;
import com.wqtz.chechai.bean.ProviceShort;

import java.util.List;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2016/12/29 14:36
 */

public class ProvinceSortAdapter extends RecyclerAdapter<ProviceShort.ResultBean.AreaListBean> {

	private RecyclerView rv;
	public callBack mBack;

	public ProvinceSortAdapter(int rsId, List<ProviceShort.ResultBean.AreaListBean> data) {
		super(rsId, data);

	}

	public void setOnItemClick(callBack mBack) {
		this.mBack = mBack;
	}


	@Override
	public int itemType(int position) {
		return 0;
	}

	@Override
	public void onBindMyViewHolder(MyHolder holder, int position, List<ProviceShort.ResultBean.AreaListBean> data) {
		TextView tv = (TextView) holder.getView(R.id.title);
		if (position == 0) {
			tv.setTextColor(Color.parseColor("#AD2928"));
		} else {
			tv.setTextColor(Color.BLACK);
		}
		holder.setText(R.id.title, data.get(position).getName());
		ProvinceSortSecondAdapter adapter = new ProvinceSortSecondAdapter(R.layout.item_province_sort, data.get(position).getProvince_list());
		rv = (RecyclerView) holder.getView(R.id.rv);
		rv.setLayoutManager(new GridLayoutManager(tv.getContext(), 4));
		rv.setAdapter(adapter);
		adapter.setCallBack(new ProvinceSortSecondAdapter.sortCallBack() {
			@Override
			public void getClickCallBack(String sort, int position) {
				mBack.getSortCallBack(sort, position);
			}
		});
	}

	public interface callBack {
		void getSortCallBack(String sort, int position);
	}
}
